
package com.market.web.form;

import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.LabelValueBean;

public class OrderSearchForm extends ActionForm
{
    /**
     * 
     */
    private static final long serialVersionUID = 7220957772979531356L;

    private String isprocessed = "";

    private String consignee = "";

    private String address = "";

    private Date fromdate;

    private Date todate;

    private String fromyy;

    private String frommm;

    private String fromdd;

    private String tomm;

    private String toyy;

    private String todd;

    private LabelValueBean[] year;

    private LabelValueBean[] month;

    private LabelValueBean[] day;

    public void reset(ActionMapping arg0, HttpServletRequest arg1)
    {
        year = new LabelValueBean[12];
        month = new LabelValueBean[12];
        day = new LabelValueBean[31];
        int yyyy = Calendar.getInstance().get(Calendar.YEAR);

        for (int i = 0; i < 12; i++)
        {
            year[i] = new LabelValueBean(String.valueOf(yyyy - i), String.valueOf(yyyy - i));
            month[i] = new LabelValueBean(String.valueOf(i + 1), String.valueOf(i + 1));
        }
        for (int i = 0; i < 31; i++)
        {
            day[i] = new LabelValueBean(String.valueOf(i + 1), String.valueOf(i + 1));
        }
    }

    public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1)
    {
        System.out.println("from :" + fromyy + "to:" + toyy);
        if (!"all".equals(fromyy) && !"all".equals(toyy))
        {
            // TODO Auto-generated method stub
            DateFormat f = DateFormat.getDateInstance();
            try
            {
                fromdate = f.parse(fromyy + "-" + frommm + "-" + fromdd);
                todate = f.parse(toyy + "-" + tomm + "-" + todd);
            }
            catch (Exception e)
            {
                // TODO: handle exception
            }
        }
        return null;
    }

    public String getAddress()
    {
        return address;
    }

    public void setAddress(String address)
    {
        this.address = address;
    }

    public String getConsignee()
    {
        return consignee;
    }

    public void setConsignee(String consignee)
    {
        this.consignee = consignee;
    }

    public Date getFromdate()
    {
        return fromdate;
    }

    public void setFromdate(Date fromdate)
    {
        this.fromdate = fromdate;
    }

    public String getFromdd()
    {
        return fromdd;
    }

    public void setFromdd(String fromdd)
    {
        this.fromdd = fromdd;
    }

    public String getFrommm()
    {
        return frommm;
    }

    public void setFrommm(String frommm)
    {
        this.frommm = frommm;
    }

    public String getFromyy()
    {
        return fromyy;
    }

    public void setFromyy(String fromyy)
    {
        this.fromyy = fromyy;
    }

    public String getIsprocessed()
    {
        return isprocessed;
    }

    public void setIsprocessed(String isprocessed)
    {
        this.isprocessed = isprocessed;
    }

    public Date getTodate()
    {
        return todate;
    }

    public void setTodate(Date todate)
    {
        this.todate = todate;
    }

    public String getTodd()
    {
        return todd;
    }

    public void setTodd(String todd)
    {
        this.todd = todd;
    }

    public String getTomm()
    {
        return tomm;
    }

    public void setTomm(String tomm)
    {
        this.tomm = tomm;
    }

    public String getToyy()
    {
        return toyy;
    }

    public void setToyy(String toyy)
    {
        this.toyy = toyy;
    }

    public LabelValueBean[] getDay()
    {
        return day;
    }

    public void setDay(LabelValueBean[] day)
    {
        this.day = day;
    }

    public LabelValueBean[] getMonth()
    {
        return month;
    }

    public void setMonth(LabelValueBean[] month)
    {
        this.month = month;
    }

    public LabelValueBean[] getYear()
    {
        return year;
    }

    public void setYear(LabelValueBean[] year)
    {
        this.year = year;
    }

}
